package bintree.leetcode;

public class Num467环绕字符串中唯一的字符串 {
    public int findSubstringInWraproundString(String p) {
        int n = p.length();
        int[] nums=new int[26];
        int cur = 0;
        int ret = 0;
        for (int i = 0; i < n; i++) {
            if (i>0&&(p.charAt(i)-p.charAt(i-1)+26)%26==1){
                cur++;
            }else {
                cur=1;
            }
            nums[p.charAt(i)-'a']=Math.max(p.charAt(i)-'a',cur);
        }
        for(int i :nums){
            ret +=i;
        }
        return ret;
    }
}
